﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DalatCooking.Core;
using DalatCooking.Core.Helper;
public partial class admin_Settings_About : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            lblInfo.Text = Setting.String("SITE_NAME");

            string appKey = AppConfig.Instance.String("ApplicationKey");
            

            if (!appKey.Equals(MyEncode.Encrypt("LeThanhTuan").ToUpper()))
            {
                pnActive.Visible = true;
                pnInfo.Visible = false;
            }
        }
    }
    protected override void OnInit(EventArgs e)
    {
        if (!IsPostBack)
        {
            Person p = Session.GetPersonLogged();
            if (!p.IsInRole("SuperUser"))
                Response.Redirect("/admin/accessdeny.aspx");
        }
        base.OnInit(e);
    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        string key = txtKey.Text.Trim();
        try
        {
            if (key.Equals(MyEncode.Encrypt("LeThanhTuan").ToUpper()))
            {
                lblOk.Text = "Key hợp lệ. Kích hoạt thành công.";
                 AppConfig.Instance.SetValue("ApplicationKey", key);
                 Response.Redirect(Request.RawUrl);
            }
            else
            {
                lblOk.Text = "Key không hợp lệ.";
            }
        }
        catch
        {
            lblOk.Text = "Key không hợp lệ.";
        }
    }
}